package com.space.base;

import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

/**
 * @author zhaixianhao
 */
public class BasePO implements Serializable {
    @ApiModelProperty("主键id")
    private String id;

    protected BasePO(final BasePO.BasePOBuilder<?, ?> b) {
        this.id = b.id;
    }

    public static BasePO.BasePOBuilder<?, ?> builder() {
        return new BasePO.BasePOBuilderImpl();
    }

    public String getId() {
        return this.id;
    }

    public void setId(final String id) {
        this.id = id;
    }

    @Override
    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof BasePO)) {
            return false;
        } else {
            BasePO other = (BasePO)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                Object this$id = this.getId();
                Object other$id = other.getId();
                if (this$id == null) {
                    if (other$id != null) {
                        return false;
                    }
                } else if (!this$id.equals(other$id)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(final Object other) {
        return other instanceof BasePO;
    }

    @Override
    public int hashCode() {
        boolean PRIME = true;
        int result = 1;
        Object $id = this.getId();
        result = result * 59 + ($id == null ? 43 : $id.hashCode());
        return result;
    }

    @Override
    public String toString() {
        return "BasePO(id=" + this.getId() + ")";
    }

    public BasePO() {
    }

    public BasePO(final String id) {
        this.id = id;
    }

    private static final class BasePOBuilderImpl extends BasePO.BasePOBuilder<BasePO, BasePO.BasePOBuilderImpl> {
        private BasePOBuilderImpl() {
        }

        @Override
        protected BasePO.BasePOBuilderImpl self() {
            return this;
        }
        @Override
        public BasePO build() {
            return new BasePO(this);
        }
    }

    public abstract static class BasePOBuilder<C extends BasePO, B extends BasePO.BasePOBuilder<C, B>> {
        private String id;

        public BasePOBuilder() {
        }
        protected abstract B self();
        public abstract C build();

        public B id(final String id) {
            this.id = id;
            return this.self();
        }

        @Override
        public String toString() {
            return "BasePO.BasePOBuilder(id=" + this.id + ")";
        }
    }
}

